//
//  FullScreenPlayerController.m
//  ProjectDemo
//
//  Created by IOS3 on 2018/11/14.
//  Copyright © 2018 IOS3. All rights reserved.
//

#import "FullScreenPlayerController.h"


@interface FullScreenPlayerController ()<WMPlayerDelegate>

@end




@implementation FullScreenPlayerController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.player];
    [self.player mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.view);
    }];
    self.player.delegate = self;
}

- (void)wmplayer:(WMPlayer *)wmplayer clickedLockButton:(UIButton *)lockBtn {
    
}
- (void)wmplayer:(WMPlayer *)wmplayer clickedCloseButton:(UIButton *)backBtn {
    [self fullScreenPlayerControllerWillDismiss];
}
- (void)wmplayer:(WMPlayer *)wmplayer clickedFullScreenButton:(UIButton *)fullScreenBtn {
    [self fullScreenPlayerControllerWillDismiss];
}



- (void)fullScreenPlayerControllerWillDismiss {
    [self dismissViewControllerAnimated:NO completion:nil];
    [self.player removeFromSuperview];
    if (self.fullScreenPlayerDismissed) {
        self.fullScreenPlayerDismissed(self.player);
    }
}


- (BOOL)shouldAutorotate {
    return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeRight;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    
    UIDeviceOrientation orientation = UIDevice.currentDevice.orientation;
    
    UIInterfaceOrientationMask orientationMask = UIInterfaceOrientationMaskLandscapeRight;
    if (orientation == UIDeviceOrientationLandscapeLeft) {
        orientationMask = UIInterfaceOrientationMaskLandscapeLeft;
    }
    return orientationMask;
}

@end
